import service from '@/utils/request'

export function getPostDetailService(postId) {
  return service({
    url: `/post/detail/${postId}`,
    method: 'get'
  })
}

export function getCommentListService(data) {
    return service({
      url: `/comment/getCommentByPost`,
      method: 'get',
      params: data
    })
  }

export function getIsLikeService(params) {
    return service({
      url: `/post/isLike`,
      method: 'get',
      params: params
    })
  }
  
  export function insertLikeWithPostService(params) {
    return service({
      url: `/post/like`,
      method: 'post',
      params: params
    })
  }

  export function deleteLikeWithPostService(params) {
    return service({
      url: `/post/deleteLike`,
      method: 'delete',
      params: params
    })
  }
  

  // 获取帖子详情
export function getPostDetail(postId) {
  return service({
    url: `/post/${postId}`,
    method: 'get'
  })
}

// 获取评论列表
export function getComments(params){
  return service({
    url: '/comment/get',
    method: 'get',
    params
  })
}

// 点赞帖子
export function likePost(postId) {
  return service({
    url: `/post/${postId}/like`,
    method: 'post'
  })
}

// 取消点赞帖子
export function cancelLike(postId){
  return service({
    url: `/post/${postId}/cancelLike`,
    method: 'delete'
  })
}

// 点赞评论
export function likeComment(commentId){
  return service({
    url: `/comment/${commentId}/like`,
    method: 'post'
  })
}

// 取消点赞评论
export function cancelLikeComment(commentId){
  return service({
    url: `/comment/${commentId}/cancelLike`,
    method: 'delete'
  })
}

// 创建评论
export function createComment(data){
  return service({
    url: '/comment/create',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

// 检查点赞状态
export function checkLikeStatus(postId) {
  return service({
    url: `/post/${postId}/like-status`,
    method: 'get'
  })
}

// 检查收藏情况
export function checkFavoriteStatus(postId) {
  return service({
    url: `/post/${postId}/favorite-status`,
    method: 'get'
  })
}

// 收藏帖子
export function favoritePost(postId) {
  return service({
    url: `/post/${postId}/favorite`,
    method: 'post'
  })
}

// 取消收藏帖子
export function cancelFavoritePost(postId) {
  return service({
    url: `/post/${postId}/cancelFavorite`,
    method: 'delete' 
  })  
}

// 举报帖子
export function reportPost(data) {
  return service({
    url: `/report/addReport`,
    method: 'post',
    data,
  })
}